home *** CD-ROM | disk | FTP | other *** search
/ Aminet 34 / Aminet 34 (2000)(Schatztruhe)[!][Dec 1999].iso / Aminet / util / mouse / FreeMouse.lha / FreeMouse / Main.c < prev   
Encoding:
C/C++ Source or Header  |  1999-10-02  |  2.5 KB  |  122 lines

  1. /*****************************************************************************
  2.  
  3.   FreeMouse V1.0
  4.  
  5.   © 1998,1999 by Alastair M. Robinson
  6.  
  7.   A neat little mouse utility which can adjust the speed of your mouse in
  8.   increments of 1%.
  9.  
  10. *****************************************************************************/
  11.  
  12. #include <exec/types.h>
  13. #include <exec/memory.h>
  14. #include <exec/io.h>
  15. #include <exec/interrupts.h>
  16. #include <exec/ports.h>
  17. #include <clib/exec_protos.h>
  18. #include <clib/dos_protos.h>
  19.  
  20. #include "GUI.h"
  21. #include "Cx.h"
  22. #include "Icon.h"
  23.  
  24. struct IntuitionBase *IntuitionBase;
  25. void *GfxBase, *GadToolsBase, *LayersBase, *IconBase;
  26.  
  27. char *Main_Setup();
  28. void Main_Cleanup();
  29.  
  30. struct CxContext *Cx;
  31. struct GUIContext *GUI;
  32.  
  33. int main()
  34. {
  35.   char *error;
  36.   int i;
  37.   BOOL cont;
  38.  
  39.   if(!(error=Main_Setup()))
  40.   {
  41.     PutStr("Everything setup OK!\n");
  42.     if(MatchToolType("CX_POPUP","YES"))
  43.       GUI->Show(GUI);
  44.     do
  45.     {
  46.       unsigned long sigs;
  47.       sigs=GUI->Signals|Cx->Signals;
  48.       sigs=Wait(sigs);
  49.       cont=GUI->Handle(GUI,sigs);
  50.       cont&=Cx->Handle(Cx,sigs);
  51.     } while(cont);
  52.   }
  53.   else
  54.   {
  55.     PutStr(error); PutStr("\n");
  56.   }
  57.   Main_Cleanup();
  58.   return(0);
  59. }
  60.  
  61.  
  62. char *Main_Setup()
  63. {
  64.   char *error;
  65.  
  66.   if(!(IconBase=OpenLibrary("icon.library",0)))
  67.     return("Can't open Icon library!");
  68.   if(!(GadToolsBase=OpenLibrary("gadtools.library",0)))
  69.     return("Can't open Gadtools library!");
  70.   if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0)))
  71.     return("Can't open Intuition library!");
  72.   if(!(GfxBase=OpenLibrary("graphics.library",0)))
  73.     return("Can't open Graphics library!");
  74.   if(!(LayersBase=OpenLibrary("layers.library",0)))
  75.     return("Can't open Layers library!");
  76.  
  77.   if(!Icon_Setup())
  78.     return("Problems with Icon!");
  79.  
  80.   if(!Commodities_Setup())
  81.     return("Can't open commodities.library");
  82.  
  83.   if(!(GUI=CreateGUI()))
  84.     return("Can't create GUI!");
  85.  
  86.   if(!(Cx=CreateCxContext(GUI)))
  87.     return("Can't create CxContext!");
  88.  
  89.   return(NULL);
  90. }
  91.  
  92.  
  93. void Main_Cleanup()
  94. {
  95.   if(GUI)
  96.     GUI->Dispose(GUI);
  97.   GUI=NULL;
  98.   if(Cx)
  99.     Cx->Dispose(Cx);
  100.   Cx=NULL;
  101.   Commodities_Cleanup();
  102.   Icon_Cleanup();
  103.  
  104.   if(GadToolsBase)
  105.     CloseLibrary(GadToolsBase);
  106.   GadToolsBase=NULL;
  107.   if(GfxBase)
  108.     CloseLibrary(GfxBase);
  109.   GfxBase=NULL;
  110.   if(IntuitionBase)
  111.     CloseLibrary((struct Library *)IntuitionBase);
  112.   IntuitionBase=NULL;
  113.   if(LayersBase)
  114.     CloseLibrary(LayersBase);
  115.   LayersBase=NULL;
  116.   if(IconBase)
  117.     CloseLibrary(IconBase);
  118.   IconBase=NULL;
  119. }
  120.  
  121.  
  122.